# -*- coding: utf-8 -*-
"""
date: Fri Dec 28 15:41:46 2018
python: Anaconda 3.6.5
author: kanade
email: kanade@blisst.cn
"""
import numpy as np


a = np.arange(1, 7)
print(a)
b = np.arange(4, 10)
print(b)
c = np.add(a, b)
print(c)
d = np.add.reduce(a)
print(d)
e = np.add.accumulate(a)
print(e)
f = np.add.reduceat(a, [0, 2, 4])
# 0   2   4
# 1 2 3 4 5 6
# 即从[0, 2)的索引相加得3，[2, 4)的索引相加得7，[4:]得11
# 所以结果为[ 3 7 11]
print(f)
g = np.add.outer([10, 20, 30], a)
print(g)
# +   1  2  3  4  5  6
# 10 11 12 13 14 15 16
# 20 ...
# 30 ...
h = np.outer([10, 20, 30], a)
print(h)
# x   1  2  3  4  5  6
# 10 10 20 30 40 50 60
# 20 ...
# 30 ...
